﻿@{
    Layout = null;
}

<!DOCTYPE html>
<html>

<head lang="en">
    <meta charset="utf-8">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,maximum-scale=1.0,user-scalable=no" />
    <title>Rong耀春甜-宝马体验营</title>
    <style>
        body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, th, td, p, pre, form, input, textarea {
            padding: 0;
            margin: 0;
        }

        table {
            border-collapse: collapse;
            border-spacing: 0;
        }

        ol, ul {
            list-style: none;
        }

        img {
            border: 0 none;
            display: block;
        }

        a {
            outline: none;
            outline: none;
            text-decoration: none;
        }

            a:focus {
                outline: none;
                -moz-outline: none;
            }

        em, strong {
            font-weight: normal;
            font-style: normal;
        }

        html, body {
            font: 14px/20px "5B8B4F53";
            height: 100%;
            overflow: hidden;
            background: #000;
        }

        .wrap {
            background: url(images/inputTxt.png) repeat;
            background-size: cover;
            width: 266px;
            height: 307px;
            position: absolute;
            left: 50%;
            top: 50%;
            margin: -153px 0 0 -128px;
        }

        .w_txt, .w_btn {
            border: 0 none;
            background: 0 none;
            width: 230px;
            height: 40px;
            position: absolute;
            top: 168px;
            left: 50%;
            margin-left: -115px;
            text-indent: 8px;
        }

        .w_btn {
            display: block;
            top: 225px;
            height: 60px;
        }
    </style>
    <link href="../Themes/RongJi/Style/Games/CarRace/src/style.css?v=2" rel="stylesheet">
    <script language="JavaScript" type="text/javascript">
        var portalCode = 'rongji365';
        var orderNumber = '@Request.QueryString["orderNumber"]';
        var saveResult = {};
        var score = 0;
        var rootPath = "../Themes/RongJi/Style/Games/CarRace/";
    </script>


    <script src="../Themes/RongJi/Style/Games/CarRace/lib/easeljs-0.7.1.min.js"></script>
    <script src="../Themes/RongJi/Style/Games/CarRace/lib/tweenjs-0.5.1.min.js"></script>
    <script src="../Themes/RongJi/Style/Games/CarRace/lib/preloadjs-0.4.1.min.js"></script>
    <script src="../Themes/RongJi/Style/Games/CarRace/lib/movieclip-0.7.1.min.js"></script>
    <script src="../Themes/RongJi/Style/Games/CarRace/lib/soundjs-0.5.2.min.js"></script>
    <script src="../Themes/RongJi/Style/Games/CarRace/common/common.js"></script>
    <script src="../Themes/RongJi/Style/Games/CarRace/src/app.js?v=1"></script>
    <script src="../Themes/RongJi/Style/Games/CarRace/src/loadingContent.js"></script>
    <script src="../Themes/RongJi/Style/Games/CarRace/src/screenContent.js"></script>
    <script src="../Themes/RongJi/Style/Games/CarRace/src/parameters.js"></script>
    <script src="../Themes/RongJi/Style/Games/CarRace/loading.js"></script>
    <script src="../Themes/RongJi/Style/Games/CarRace/main.js"></script>
</head>

<body id="bodyMain" onload="initLoading();" style="background-color: #666666">
    <div id="inputNamePanel" class="wrap">
        <input class="w_txt" id="usernameInput" type="text" maxlength="8" value="    请输入！如：小鲜" onfocus="javascript:inputFocus();">
        <a class="w_btn" id="wBtn" href="javascript:inputNamePanelStartGame();"></a>
    </div>
    <div id="loading" class="div-loading">
        <canvas id="canvasLoading" width="640" height="1008">sorry,your browser dosen't support html5</canvas>
        <style>
            * {
                margin: 0;
                padding: 0;
            }

            #a {
                display: block;
                background-color: gray;
            }
        </style>
    </div>
    <div id="main" class="div-main">
        <canvas id="canvas" width="640" height="1008">sorry,your browser dosen't support html5</canvas>
        <style>
            * {
                margin: 0;
                padding: 0;
            }

            #a {
                display: block;
                background-color: gray;
            }
        </style>
    </div>
    <script language="JavaScript" type="text/javascript">

        var picArr = [];//记录大图小图的数组;
        var canvasLoading, canvas, stage, loadingStage, exportRoot;
        var queue;
        var scale = 1;
        var picNum = 0;//主文件已加载图片数量;
        var picTotal = 0;//主文件图片数量总和;
        var loadingProgress = 0;//loading百分比;

        var loadingPanel;//loading对象;
        var appPanel;//app主体对象;
        var screenPanel;//其他场景对象;
        var model = new createjs.MovieClip();//用于发送事件;

        var _fps, $time, $count = 0;

        init();

        function init() {
            inputNamePanelDisplay(false);//隐藏输入名称面板;
            // onBridgeInit();//朋友圈;
            tcssComplete();//监测代码;
            queue = new createjs.LoadQueue(true);

            var tmpStr = 3;//getQueryString('heartNum');
            console.log('heartNum:', tmpStr);
            HEARTNUM = Number(tmpStr);



            //SHARE_URL = 'http://roco.qq.com/act/a20141208game/index.html?heartNum=' + HEARTNUM.toString();//分享地址;
        }

        //loading canvas加载完成的时候会调用该函数;
        function initLoading() {
            canvasLoading = document.getElementById('canvasLoading');

            loadingImages = loadingImages || {};

            var loader = new createjs.LoadQueue(false);
            loader.addEventListener("fileload", loadingHandleFileLoad);
            loader.addEventListener("complete", loadingHandleComplete);
            loader.loadManifest(loadingLib.properties.manifest);

            //initMain();


        }



        //loading过程中加载图片素材;
        function loadingHandleFileLoad(evt) {
            if (evt.item.type == "image") { loadingImages[evt.item.id] = evt.result; }
        }
        //loading素材加载完成;
        function loadingHandleComplete() {
            exportRoot = new loadingLib.loading();

            stage = new createjs.Stage(canvasLoading);
            stage.addChild(exportRoot);
            stage.update();

            createjs.Ticker.setFPS(loadingLib.properties.fps);
            createjs.Ticker.addEventListener("tick", stage);

            //初始化loading内容;
            loadingPanel = new loadingObj();

            //return;

            if (isLoadBigPic) {
                //加载大图;
                queue.setMaxConnections(5);
                queue.on('complete', imagesLoadComplete, this);
                queue.on('progress', imagesLoadProgress);

                var manifestLength = lib.properties.manifest.length;
                picArr = [].concat(lib.properties.manifest);
                for (var i = 0; i < gamedataArr.length; i++) {
                    for (prop in gamedataArr[i].animations) {
                        //console.log(prop,arr[i].animations[prop]);
                        for (var j = 0; j < manifestLength; j++) {
                            if (picArr[j]) {
                                if (prop == picArr[j].id) {
                                    picArr.splice(j, 1);
                                    j -= 1;
                                }
                            }
                        }
                    }
                    picArr.push({ id: 'test' + i.toString(), src: gamedataArr[i].images[0] });
                }
                console.log(picArr);
                queue.loadManifest(picArr);
            }
            else {
                //加载小图;
                initMain();
            }
        }

        function imagesLoadProgress(e) {
            loadingProgress = e.progress;
        }

        function imagesLoadComplete(e) {
            initMain();
        }

        //
        function initMain() {
            canvas = document.getElementById('canvas');
            images = images || {};

            picTotal = lib.properties.manifest.length;

            if (isLoadBigPic) {
                //加载大图 解析大图;
                for (var i = 0; i < gamedataArr.length; i++) {
                    setImgItem(gamedataArr[i], lib, images);
                }

                for (var j = 0; j < picArr.length; j++) {
                    //console.log(picArr[j]);
                    for (var k = 0; k < picTotal; k++) {
                        if (lib.properties.manifest[k].id == picArr[j].id) {
                            images[picArr[j].id] = queue.getResult(picArr[j].id);
                        }
                    }
                }
                console.log('pic num:', picArr.length);
                initHandleComplete();
            }
            else {
                //加载小图;
                var loader = new createjs.LoadQueue(false);
                loader.addEventListener("fileload", initHandleFileLoad);
                loader.addEventListener("complete", initHandleComplete);
                loader.loadManifest(lib.properties.manifest);
            }
        }

        function initHandleFileLoad(evt) {
            picNum += 1;
            loadingProgress = picNum / picTotal;
            //console.log(loadingProgress);
            if (evt.item.type == "image") { images[evt.item.id] = evt.result; }
        }

        function initHandleComplete() {
            console.log('handleCompleteInit');

            exportRoot = new lib.main();

            stage = new createjs.Stage(canvas);
            stage.addChild(exportRoot);
            stage.update();

            if (isNeedFps) {
                _fps = new createjs.Text("0", "900 36px Arial", "#000000");
                stage.addChild(_fps);
                $time = new Date().getTime();
            }


            createjs.Ticker.setFPS(lib.properties.fps);
            createjs.Ticker.addEventListener("tick", stageFun);

            createjs.EventDispatcher.initialize(model);

            //new app.init();
            screenPanel = new screenObj();
            screenPanel.init();

            appPanel = new appObj();
            appPanel.init();

            //test;
            //loadingNone();
            //gameStart();
        }

        //由于大图解析成小图需要一个过度时间3-4s,所以需要先用loading遮挡;
        function loadingNone() {
            stage.removeChild(loading);
            document.getElementById('loading').style.display = "none";
        }

        //帧频显示;
        function stageFun() {
            if (isNeedFps) {
                $count++;
                var now = new Date().getTime();
                if (now - $time > 1000) {
                    _fps.text = "fps:" + Math.round($count * 10000 / (now - $time)) / 10 + '/' + lib.properties.fps;
                    $time = now;
                    $count = 0;
                }
            }
            stage.update();
        }

        function gameStart() {
            alert("gameStart");
        }

        function gameOver() {
            alert("gameOver");
        }

        function inputNamePanelStartGame() {
            //alert('inputNamePanelStartGame');
            username = document.getElementById('usernameInput').value;
            if (username == '    请输入！如：小鲜' || username == '') {
                username = '小鲜';
            }
            //alert(username);
            inputNamePanelDisplay(false);
            appPanel.startGame();
        }

        function inputNamePanelDisplay(arg) {
            if (arg == true) {
                document.getElementById('inputNamePanel').style.display = 'block';
            }
            else {
                document.getElementById('inputNamePanel').style.display = 'none';
            }
        }

        function inputFocus() {
            username = document.getElementById('usernameInput').value;
            if (username == '    请输入！如：小鲜') {
                //username='默认名称';
                document.getElementById('usernameInput').value = '';
            }
        }

        var sw = window.screen.width, sh = (sw * 296) / 256;
        function g(id) { return document.getElementById(id); }
        //	alert(window.screen.width);
        if (window.screen.width <= 640) {
            g("inputNamePanel").style.width = sw + "px";
            g("inputNamePanel").style.height = sh + "px";
            g("inputNamePanel").style.marginLeft = -(sw / 2) + "px";
            g("inputNamePanel").style.marginTop = -(sh / 2) + "px";
            g("usernameInput").style.width = sw * 0.6 + "px";
            g("usernameInput").style.marginLeft = -(sw * 0.6 / 2) + "px";
            g("usernameInput").style.top = sh * 0.555 + "px";
            g("wBtn").style.top = sh * 0.735 + "px";
            g("wBtn").style.width = sw * 0.9 + "px";
            g("wBtn").style.marginLeft = -(sw * 0.9 / 2) + "px";
            g("wBtn").style.height = sh * 0.2 + "px";
        }
    </script>
    <script type="text/javascript" src="http://m.rongji365.com/Themes/RongJi/Style/base/js/jquery-1.10.1.min.js"></script>
    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script>
        function onBridgeReady() {
            WeixinJSBridge.call('hideOptionMenu');
        }

        if (typeof WeixinJSBridge == "undefined") {
            if (document.addEventListener) {
                document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
            } else if (document.attachEvent) {
                document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
            }
        } else {
            onBridgeReady();
        }

        $(function () {
            var postData = {
                "currentUrl": location.href.split('#')[0]
            }
            $.post("/WeixinJsSdk/ConfigScriptJson?portal=" + portalCode, postData, function (wxConfig) {

                // wxConfig.debug = true;
                wxConfig.jsApiList.push("hideOptionMenu");
                wx.config(wxConfig);

                wx.ready(function () {
                    wx.hideOptionMenu();
                });

                wx.error(function (res) {

                    // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。

                });
            });
        });
    </script>
</body>

</html>
<!--[if !IE]>|xGv00|a221b93aaaa31cf3dcd8f6ed331efa79<![endif]-->